import axios from 'axios';
import utils from '@/utils/index';

const service = axios.create({
    // 超时时间
    timeout: 300000,
});
// 请求拦截
service.interceptors.request.use(
    (config) => {
        console.log(window.location.href,'000000');
        let token = ''
        if(window.location.href.includes('orderHome')){
            token = utils.getCache('Ctoken')

        }else{
            token = utils.getCache('token')
        }
        config.headers['Authorization'] = token
        config.baseURL = process.env.VUE_APP_BASE_API;
        return config;
    },
    (err) => {

        utils._msgBox(err, 'error');
    },
);

// 响应拦截
service.interceptors.response.use(
    (response) => {

        return response.data;
    },
    (err) => {
        // 请求报错
        utils._msgBox(err, 'error');
    },
);

export default service


